package com.zhouqinuan.spring.cloud.develop.framework.demo.xxljob.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.zhouqinuan.spring.cloud.develop.framework.demo.xxljob.mapper.UserInfoMapper;
import com.zhouqinuan.spring.cloud.develop.framework.demo.xxljob.model.UserInfo;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class UserService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @XxlJob("xxljob-demoJobHandler")
    public ReturnT<String> demoJobHandler(String param) throws Exception {
        log.info("demoJobHandler start...");

        UserInfo userInfo = userInfoMapper.selectByPrimaryKey(1L);
        log.info("{}", JSON.toJSONString(userInfo));

        log.info("demoJobHandler end");

        return ReturnT.SUCCESS;
    } 
}
